import Vue from 'vue'
// import VueRouter from 'vue-router'
import KRouter from '../kRouter'
import Home from '../views/Home.vue'
import MyUser from '@pages/myUser/myUser.vue'

/*
VueRouter是一个插件,内部实现如下功能:
1)内部实现了router-view,router-link组件
2)将$router挂载到Vue原型上,之后所有组件都可以使用$router
3)最后将VueRouter对象在main.js中使用,当参数传递到Vue初始化实例中
*/
// 调用插件中install方法,早于new VueRouter()实例的创建
// Vue.use(VueRouter)
Vue.use(KRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  {
    path: '/myUser',
    name: 'myUser',
    component: MyUser
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = new KRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
